﻿using BLL;
using IBLL;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Models;

namespace WebAPIUI.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HouseNumController : ControllerBase
    {
        public HouseNumController(IHouseNumBLL bLL )
        {
            BLL = bLL;
        }

        public IHouseNumBLL BLL { get; }


        [HttpPost]
        public async Task<int> AddHouseNum(HouseNum house)
        {
            return  await BLL.AddHouseNum(house);
        }

        [HttpGet]
        public dynamic GetHouseNumPageWhere(int index, int size, decimal pmin, decimal pmax, int State)
        {
           return  BLL.GetHouseNumPageWhere(index,size,pmin,pmax,State);
        }


        /// <summary>
        /// 批量真删除
        /// </summary>
        /// <param name="idstring">由逗号分隔的id字符串</param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> DeleteRange(string idstring)
        {
            return await BLL.DeleteRange(idstring);
        }

        /// <summary>
        /// 批量逻辑删除【状态修改】
        /// 本质是修改
        /// </summary>
        /// <param name="idstring"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> DeleteRangeLogic(string idstring)
        {
           return await BLL.DeleteRangeLogic(idstring);
        }

        /// <summary>
        /// 空闲和已预订修改
        /// 本质是修改
        /// </summary>
        /// <param name="idstring"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<int> UpdateState(string idstring)
        {
         return await BLL.UpdateState(idstring);
        }
    }
}
